package com.shencai.demo.base.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shencai.demo.base.entity.SysMenu;
import com.shencai.demo.base.entity.SysUser;
import com.shencai.demo.base.entity.SysUserRole;
import com.shencai.demo.base.service.SysUserRoleService;
import com.shencai.demo.base.mapper.SysUserRoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author sckj
 * @description 针对表【sys_user_role(用户与角色关联表)】的数据库操作Service实现
 * @createDate 2022-10-19 11:04:48
 */
@Service
public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole>
        implements SysUserRoleService{

    @Autowired
    private SysUserRoleMapper sysUserRoleMapper;

    @Override
    public List<SysUserRole> userRoleByUserId(Integer userId) {
        LambdaQueryWrapper<SysUserRole> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(SysUserRole::getUserId,userId);
        List<SysUserRole> sysUserRoles = sysUserRoleMapper.selectList(lambdaQueryWrapper);

        return sysUserRoles;
    }
}